package com.codegenerate.demo.dto; /**
========= dto ==========
*/

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codegenerate.demo.config.R;
import com.codegenerate.demo.entity.SysAccount;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

public class SysAccountDto implements Serializable {
  private long id;

    int pageNum;
     int pageSize;
       public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

   public R validateUpdate(){
        if(this.getId()<0){
                   return R.failed("id 不能为空");
          }
        return R.ok(null);
    }


   

  
        
            /**
            * 服务器编号ID
            */
            private long serverNumber;
        

   
        
            /**
            * 最近更新时间
            */
            private LocalDateTime lastEditTime;
        

   
        
            /**
            * 最近更新人ID
            */
            private long editUserId;
        

   
        
            /**
            * 最近更新人
            */
            private String editUser;
        

   
        
            /**
            * 添加时间
            */
            private LocalDateTime addTime;
        

   
        
            /**
            * 添加人ID
            */
            private long addUserId;
        

   
        
            /**
            * 添加人
            */
            private String addUser;
        

   
        
            /**
            * 有效状态[数据字典=del_state] 1有效  5删除
            */
            private long delState;
        

   
        
            /**
            * 租户ID
            */
            private long tenantId;
        

   
        
            /**
            * 租户类型 1应用管理者2应用消息者
            */
            private long tenantType;
        

   
        
            /**
            * 最近一次登录IP
            */
            private String lastIp;
        

   
        
            /**
            * 最近登录时间
            */
            private LocalDateTime lastLoginTime;
        

   
        
            /**
            * IP锁定可支持多个IP用逗号隔开
            */
            private String ip;
        

   
        
            /**
            * ip锁定状态[查询]0未锁定1己锁定
            */
            private long ipState;
        

   
        
            /**
            * 是否为超级管理员[查询]
            */
            private long isAdmin;
        

   
        
            /**
            * 在线状态[数据字典=OnlieState]
            */
            private long onlieState;
        

   
        
            /**
            * 账号状态[数据字典=AccountState]  1正常  5己停用
            */
            private long state;
        

   
        
            /**
            * 累计登录次数
            */
            private long loginNum;
        

   
        
            /**
            * 登录密码
            */
            private String passWord;
        

   
        
            /**
            * 登录用户名
            */
            private String userName;
        

   
        
        

   





    
           public long getServerNumber() {
             return serverNumber;
          }
          public void setServerNumber(long serverNumber) {
                 this.serverNumber = serverNumber;
          }   
   
           public LocalDateTime getLastEditTime() {
             return lastEditTime;
          }
          public void setLastEditTime(LocalDateTime lastEditTime) {
                 this.lastEditTime = lastEditTime;
          }   
   
           public long getEditUserId() {
             return editUserId;
          }
          public void setEditUserId(long editUserId) {
                 this.editUserId = editUserId;
          }   
   
           public String getEditUser() {
             return editUser;
          }
          public void setEditUser(String editUser) {
                 this.editUser = editUser;
          }   
   
           public LocalDateTime getAddTime() {
             return addTime;
          }
          public void setAddTime(LocalDateTime addTime) {
                 this.addTime = addTime;
          }   
   
           public long getAddUserId() {
             return addUserId;
          }
          public void setAddUserId(long addUserId) {
                 this.addUserId = addUserId;
          }   
   
           public String getAddUser() {
             return addUser;
          }
          public void setAddUser(String addUser) {
                 this.addUser = addUser;
          }   
   
           public long getDelState() {
             return delState;
          }
          public void setDelState(long delState) {
                 this.delState = delState;
          }   
   
           public long getTenantId() {
             return tenantId;
          }
          public void setTenantId(long tenantId) {
                 this.tenantId = tenantId;
          }   
   
           public long getTenantType() {
             return tenantType;
          }
          public void setTenantType(long tenantType) {
                 this.tenantType = tenantType;
          }   
   
           public String getLastIp() {
             return lastIp;
          }
          public void setLastIp(String lastIp) {
                 this.lastIp = lastIp;
          }   
   
           public LocalDateTime getLastLoginTime() {
             return lastLoginTime;
          }
          public void setLastLoginTime(LocalDateTime lastLoginTime) {
                 this.lastLoginTime = lastLoginTime;
          }   
   
           public String getIp() {
             return ip;
          }
          public void setIp(String ip) {
                 this.ip = ip;
          }   
   
           public long getIpState() {
             return ipState;
          }
          public void setIpState(long ipState) {
                 this.ipState = ipState;
          }   
   
           public long getIsAdmin() {
             return isAdmin;
          }
          public void setIsAdmin(long isAdmin) {
                 this.isAdmin = isAdmin;
          }   
   
           public long getOnlieState() {
             return onlieState;
          }
          public void setOnlieState(long onlieState) {
                 this.onlieState = onlieState;
          }   
   
           public long getState() {
             return state;
          }
          public void setState(long state) {
                 this.state = state;
          }   
   
           public long getLoginNum() {
             return loginNum;
          }
          public void setLoginNum(long loginNum) {
                 this.loginNum = loginNum;
          }   
   
           public String getPassWord() {
             return passWord;
          }
          public void setPassWord(String passWord) {
                 this.passWord = passWord;
          }   
   
           public String getUserName() {
             return userName;
          }
          public void setUserName(String userName) {
                 this.userName = userName;
          }   
   
           public long getId() {
             return id;
          }
          public void setId(long id) {
                 this.id = id;
          }   
   

 

        /**
        * build
        */
       public static SysAccountDto build(){
            SysAccountDto temp = new SysAccountDto();

                  temp.setServerNumber(0L);
            
                  temp.setLastEditTime(LocalDateTime.now());
            
                  temp.setEditUserId(0L);
            
                  temp.setEditUser("");
            
                  temp.setAddTime(LocalDateTime.now());
            
                  temp.setAddUserId(0L);
            
                  temp.setAddUser("");
            
                  temp.setDelState(1);
            
                  temp.setTenantId(0L);
            
                  temp.setTenantType(0L);
            
                  temp.setLastIp("");
            
                  temp.setLastLoginTime(LocalDateTime.now());
            
                  temp.setIp("");
            
                  temp.setIpState(0L);
            
                  temp.setIsAdmin(0L);
            
                  temp.setOnlieState(0L);
            
                  temp.setState(0L);
            
                  temp.setLoginNum(0L);
            
                  temp.setPassWord("");
            
                  temp.setUserName("");
            
                  temp.setId(0L);
            

            return temp;
    }

    /**
        * setDefaultValue
        */
       public void  setDefaultValue(SysAccountDto temp){
            
                    if(this.serverNumber<=0){
                                temp.setServerNumber(0L);
                    }        
            
                    if(null==this.lastEditTime){
                                temp.setLastEditTime(LocalDateTime.now());
                    }        
            
                    if(this.editUserId<=0){
                                temp.setEditUserId(0L);
                    }        
            
                    if(StringUtils.isEmpty(this.editUser)){
                                temp.setEditUser("");
                    }        
            
                    if(null==this.addTime){
                                temp.setAddTime(LocalDateTime.now());
                    }        
            
                    if(this.addUserId<=0){
                                temp.setAddUserId(0L);
                    }        
            
                    if(StringUtils.isEmpty(this.addUser)){
                                temp.setAddUser("");
                    }        
            
                    if(this.delState<=0){
                                temp.setDelState(1);
                    }        
            
                    if(this.tenantId<=0){
                                temp.setTenantId(0L);
                    }        
            
                    if(this.tenantType<=0){
                                temp.setTenantType(0L);
                    }        
            
                    if(StringUtils.isEmpty(this.lastIp)){
                                temp.setLastIp("");
                    }        
            
                    if(null==this.lastLoginTime){
                                temp.setLastLoginTime(LocalDateTime.now());
                    }        
            
                    if(StringUtils.isEmpty(this.ip)){
                                temp.setIp("");
                    }        
            
                    if(this.ipState<=0){
                                temp.setIpState(0L);
                    }        
            
                    if(this.isAdmin<=0){
                                temp.setIsAdmin(0L);
                    }        
            
                    if(this.onlieState<=0){
                                temp.setOnlieState(0L);
                    }        
            
                    if(this.state<=0){
                                temp.setState(0L);
                    }        
            
                    if(this.loginNum<=0){
                                temp.setLoginNum(0L);
                    }        
            
                    if(StringUtils.isEmpty(this.passWord)){
                                temp.setPassWord("");
                    }        
            
                    if(StringUtils.isEmpty(this.userName)){
                                temp.setUserName("");
                    }        
            
                    if(this.id<=0){
                                temp.setId(0L);
                    }        
            
    }



    /**
        * dto2entity
        */
       public SysAccount  dto2entity(){
            var entity= SysAccount.build();
            
                    if(this.serverNumber>0){
                       entity.setServerNumber(this.getServerNumber());
                    }        
            
                    if(null!=this.lastEditTime){
                       entity.setLastEditTime(this.getLastEditTime());
                    }        
            
                    if(this.editUserId>0){
                       entity.setEditUserId(this.getEditUserId());
                    }        
            
                    if(!StringUtils.isEmpty(this.editUser)){
                       entity.setEditUser(this.getEditUser());
                    }        
            
                    if(null!=this.addTime){
                       entity.setAddTime(this.getAddTime());
                    }        
            
                    if(this.addUserId>0){
                       entity.setAddUserId(this.getAddUserId());
                    }        
            
                    if(!StringUtils.isEmpty(this.addUser)){
                       entity.setAddUser(this.getAddUser());
                    }        
            
                    if(this.delState>0){
                       entity.setDelState(this.getDelState());
                    }        
            
                    if(this.tenantId>0){
                       entity.setTenantId(this.getTenantId());
                    }        
            
                    if(this.tenantType>0){
                       entity.setTenantType(this.getTenantType());
                    }        
            
                    if(!StringUtils.isEmpty(this.lastIp)){
                       entity.setLastIp(this.getLastIp());
                    }        
            
                    if(null!=this.lastLoginTime){
                       entity.setLastLoginTime(this.getLastLoginTime());
                    }        
            
                    if(!StringUtils.isEmpty(this.ip)){
                       entity.setIp(this.getIp());
                    }        
            
                    if(this.ipState>0){
                       entity.setIpState(this.getIpState());
                    }        
            
                    if(this.isAdmin>0){
                       entity.setIsAdmin(this.getIsAdmin());
                    }        
            
                    if(this.onlieState>0){
                       entity.setOnlieState(this.getOnlieState());
                    }        
            
                    if(this.state>0){
                       entity.setState(this.getState());
                    }        
            
                    if(this.loginNum>0){
                       entity.setLoginNum(this.getLoginNum());
                    }        
            
                    if(!StringUtils.isEmpty(this.passWord)){
                       entity.setPassWord(this.getPassWord());
                    }        
            
                    if(!StringUtils.isEmpty(this.userName)){
                       entity.setUserName(this.getUserName());
                    }        
            
                    if(this.id>0){
                       entity.setId(this.getId());
                    }        
            
            return entity;
        }

    /**
     * dto2entity
     */
    public SysAccount  dto2entity(SysAccount entity){
        if(this.serverNumber>0){
            entity.setServerNumber(this.getServerNumber());
        }

        if(null!=this.lastEditTime){
            entity.setLastEditTime(this.getLastEditTime());
        }

        if(this.editUserId>0){
            entity.setEditUserId(this.getEditUserId());
        }

        if(!StringUtils.isEmpty(this.editUser)){
            entity.setEditUser(this.getEditUser());
        }

        if(null!=this.addTime){
            entity.setAddTime(this.getAddTime());
        }

        if(this.addUserId>0){
            entity.setAddUserId(this.getAddUserId());
        }

        if(!StringUtils.isEmpty(this.addUser)){
            entity.setAddUser(this.getAddUser());
        }

        if(this.delState>0){
            entity.setDelState(this.getDelState());
        }

        if(this.tenantId>0){
            entity.setTenantId(this.getTenantId());
        }

        if(this.tenantType>0){
            entity.setTenantType(this.getTenantType());
        }

        if(!StringUtils.isEmpty(this.lastIp)){
            entity.setLastIp(this.getLastIp());
        }

        if(null!=this.lastLoginTime){
            entity.setLastLoginTime(this.getLastLoginTime());
        }

        if(!StringUtils.isEmpty(this.ip)){
            entity.setIp(this.getIp());
        }

        if(this.ipState>0){
            entity.setIpState(this.getIpState());
        }

        if(this.isAdmin>0){
            entity.setIsAdmin(this.getIsAdmin());
        }

        if(this.onlieState>0){
            entity.setOnlieState(this.getOnlieState());
        }

        if(this.state>0){
            entity.setState(this.getState());
        }

        if(this.loginNum>0){
            entity.setLoginNum(this.getLoginNum());
        }

        if(!StringUtils.isEmpty(this.passWord)){
            entity.setPassWord(this.getPassWord());
        }

        if(!StringUtils.isEmpty(this.userName)){
            entity.setUserName(this.getUserName());
        }

        if(this.id>0){
            entity.setId(this.getId());
        }

        return entity;
    }

        

    public Page<SysAccount> buildPage(){
            Page<SysAccount> tempage = new Page<SysAccount>();
            tempage.setCurrent(this.getPageNum()<=0?0:this.getPageNum());
            tempage.setSize(this.getPageSize()<=0?10:this.getPageSize());
            return tempage;
     }


}